<template>
  <div>
    <h2>登录页</h2>
    <div>用户名: <input type="text" v-model="form.name"></div>
    <div>密码: <input type="text" v-model="form.pwd"></div>
    <button @click="submit">登录</button>
  </div>
</template>

<script>
export default {
  data() {
    return{
      form:{
        name:'',
        pwd:''
      }   
    }

  },
  methods:{
    submit() {
      const token = this.form.name + this.form.pwd
      // 设置本地存储
      localStorage.setItem('token' , token)
      // 获取传参过来的地址
      const redirectUrl = this.$route.query.redirectUrl || '/'
      alert('登陆成功') 
      this.$router.replace(redirectUrl)
    }
  }
}
</script>

<style>

</style>